//
//  MKUIPickerViewComponentModel.m
//  MKUI
//
//  Created by sushangjin on 15/6/18.
//  Copyright (c) 2015年 sushangjin. All rights reserved.
//

#import "MKUIPickerViewComponentModel.h"
#import "MKUIPickerViewModel.h"
#import "MKUIPickerViewCellModel.h"

@implementation MKUIPickerViewComponentModel
- (UIPickerView *)pickerView{
	return self.pickerViewModel.pickerView;
}
- (MKUIPickerViewModel *)pickerViewModel{
	return (MKUIPickerViewModel *)[self collectionModel];
}
- (NSInteger)indexOfCellModelWithTitle:(NSString *)title{
	if(!title)return NSNotFound;
	NSInteger index = [self.cellModels indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
		MKUIPickerViewCellModel *cm = (MKUIPickerViewCellModel *)obj;
		if([title isEqualToString:cm.title]){
			*stop = YES;
			return YES;
		}
		return NO;
	}];
	return index;
}
@end
